﻿using System;
using System.Windows;
using Core.Shared.Monads;

namespace UI.Resources.Controls
{
	class WarningMessageBox
	{
		public WarningMessageBox(string errorLabelKey, string errorTextKey)
		{
			_errorLabel = errorLabelKey;
			_errorText = errorTextKey;
		}

		#region Private fields

		private readonly string _errorLabel;

		private readonly string _errorText;

		#endregion

		public void Show(Action successAction)
		{
			Show(successAction, null);
		}

		public void Show(Action successAction, Action failureAction)
		{
			if (MessageBox.Show(_errorText, _errorLabel, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) {
				successAction.Do(action => action());
			}
			else
			{
				failureAction.Do(action => action());
			}
		}
	}
}